"""
随机产生算式
"""
import random

def random_formula(op_length=1,operator=('+','-','*','/'))->str:
    """
    随机产生计算式
    op_length 算式操作符数量
    operator  算符
    """
    formula = ''
    random.seed()
    formula += str(random.randint(0,100))
    for i in range(op_length):
        formula += operator[random.randint(0,len(operator)-1)]
        formula += str(random.randint(0,100))

    return formula

def combo_formula(formulas,operator=('+','-','*','/'))->str:
    """
    将简单的算式加括号进行组合成复杂
    """
    for i,iter_formula in enumerate(formulas):
        if i==0:
            formula = f"({iter_formula}){operator[random.randint(0,len(operator)-1)]}"
        else:
            formula += f"{operator[random.randint(0,len(operator)-1)]}({iter_formula})"
    return formula

def complex_formula(level=1,op_length=1,operator=('+','-','*','/'))->str:
    """
    随机产生复杂的算式
    level 括号嵌套深度最大值,会产生随机数random.randint(1,level)
    op_length 操作数嵌套最大长度
    operator  用到的操作
    """
    formula = ''
    for i in range(level):
        pass
    return formula
